<template>
  <div class="list-table">
    <div class="area-header">
      <span class="area-header-title">{{ $t('人员详情') }}</span>
    </div>
    <el-table
      v-loading="loading"
      :data="hrSituationList"
      :model="queryParams"
      border
      tooltip-effect="darkTable"
      style="width:100%"
      height="600"
    >
      <el-table-column :label="$t('序号')" type="index" align="center" show-overflow-tooltip width="50">
        <template slot-scope="scope">
          {{ (queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1 }}
        </template>
      </el-table-column>
      <el-table-column :label="$t('姓名')" align="center" prop="name">
        <template slot-scope="scope">
          <router-link
            target="_blank"
            :to="{path:'/oa/hr/base/hrBaseHome',query:{hrId:scope.row.id,menuPath: menuKey}}"
            class="link_a"
          >{{ scope.row.name }}</router-link>
        </template>
      </el-table-column>
      <el-table-column :label="$t('部门')" align="center" prop="deptName" />
      <el-table-column :label="$t('入职时间')" align="center" prop="entryTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.entryTime) }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('离职时间')" align="center" prop="quitTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.quitTime) }}</span>
        </template>
      </el-table-column>
    </el-table>
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import { listHrType } from '@/api/oa/hr/hrBaseReport'
export default {

  data() {
    return {
      // 遮罩层
      loading: true,
      // 总条数
      total: 0,
      // 人员情况-表格数据
      hrSituationList: [],
      // 查询参数
      queryParams: {
        name: undefined,
        positionName: undefined,
        entryTime: undefined,
        deptId: undefined,
        hrType: undefined,
        startDate: undefined,
        endDate: undefined,
        pageNum: 1,
        pageSize: 10
      },
      menuKey: ''
    }
  },
  watch: {
    '$route': {
      handler(val) {
        this.menuKey = val.query.menuKey
      },
      deep: true,
      immediate: true
    }
  },
  created() {
    this.getList()
  },
  methods: {
    // 查询通知列表
    getList() {
      this.loading = true
      listHrType(this.queryParams).then(response => {
        this.hrSituationList = response.rows
        this.total = response.total
        this.loading = false
      })
    },
    findHandle(row, hrType) {
      this.queryParams.startDate = row.startDate
      this.queryParams.endDate = row.endDate
      this.queryParams.deptId = row.deptId
      this.queryParams.hrType = hrType
      this.getList()
    },
    // 表单重置
    reset() {
      this.form = {}
      this.resetForm('form')
    }
  }
}
</script>
